// pages/map/wxplugin-citySelector.js
const citySelector = requirePlugin('citySelector');
// console.log(citySelector)
Component({
    /**
     * 组件的属性列表
     */
    properties: {},

    /**
     * 组件的初始数据
     */
    data: {
        address: "",
        locationName: "",
    },

    /**
     * 组件的方法列表
     */
    methods: {
        onLoad() {

        },

        // 从城市选择器插件返回后，在页面的onShow生命周期函数中能够调用插件接口，获取cityInfo结果对象
        onShow() {
            const selectedCity = citySelector.getCity(); // 选择城市后返回城市信息对象，若未选择返回null
            console.log(selectedCity)
            if (selectedCity) {
                this.setData({
                    address: location.address ? location.address : "",
                    locationName: location.name ? location.name : ""
                });
            }
        },

        //显示地图
        showMap() {
            const key = "YBEBZ-HABWB-SKHUH-JUPM5-DEBBV-IIFIG";
            const referer = "益智时间-map";

           /* const key = "Q3TBZ-HS23G-EN3QQ-QTPPX-VX766-64FFD";
            const referer = "yztime";*/

          /*  const key = "G6DBZ-PVK6V-6QUP4-5V242-TTCTE-PZFJM";
            const referer = "202310111059";*/

            wx.navigateTo({
                 url: 'plugin://citySelector/index?key=' + key + '&referer=' + referer
            });
        },

        onUnload() {
            // 页面卸载时清空插件数据，防止再次进入页面，getCity返回的是上次的结果
            citySelector.clearCity();
        }
    }
})

